

<?
$Page->title = 'Страницы';
?>



<?
echo  '<p>'.$lang['page']['message'].'</p>';

// for each page show page block
show_pages_boxes();
  
//pr($theme);  
//exit;    

return;
    
	
	
// function show_page_box - we can use it by recursion
// @param $page - array with $page general data (from pages_index)
function show_pages_boxes($parent_id = 0) 
{
global $lang, $Page;
$templ_folder = $Page->content_template_folder;
//pr($Page->data);    
    
foreach ($Page->data as $page)
{
    
	// $page = (array)$page;
	// pr($page);
	
	
	
	if ($page->parent_id != $parent_id) continue;   
    
	$level = count(explode('/',$page->url_original))-2;
    
    // calculate the margin.
    $margin = $level* 40 + 10;

	

    //pr($margin);
    
    
	?>

<?/*** Тулбар страницы ***/?>    
    <div class="menudiv" 
    <? if ($margin != 0) echo "style='margin-left:{$margin}px;' "; ?>
    >

<?/* Иконка страницы */?>    
	
	<? $img = $page->url_rewrite 
				? 	Admin::$img_folder."/link_page.png"
				:	($page->img
						? Image::thumb($page->img, 36,36,1) 
						: "$templ_folder/images/page.png" ); 
	
	$title= $page->url_rewrite ? 'Страница-ссылка: '.$page->url_rewrite : '';
	?>
	
	<span><img src="<?=$img?>" title="<?=$title?>" ></span>
    
    
<?/* Название страницы */?>    
    
    <span class="title-page"  
    <?=(!$page->show? 'style="color:#ccc;" ':'')?>
    ><a href="/admin/site/edit_page/<?=$page->id?>/?<?=ReturnURL::$suffix?>" 
    title="<?=$lang['page']['edit']?>"
    ><?=$page->title;?> 
    </a></span> 
    		
         
        
    
<?/* Редактировать */?>   
	
    <span>
        <a href="/admin/site/edit_page/<?=$page->id?>?<?=ReturnURL::$suffix?>" >
            <img src="<?=$templ_folder?>/images/edit.png" 
            title="<?php echo $lang['page']['edit']; ?>" 
            alt=  "<?php echo $lang['page']['edit']; ?>" />
        </a>
    </span>

<?/* Посмотреть на сайте */?>       

    <span style='border:0px solid #ccc;'>
        <a href="<?=$page->url?>" target=_blank  >
            <img src="<?=$templ_folder?>/images/viewpage.png" 
            title="<?=$lang['page']['viewpage']; ?>" 
            alt=  "<?=$lang['page']['viewpage']; ?>" />
        </a>
    </span>
  

	
<?/* Вкл/выкл страницу */?>   
			
    <span style='border:0px solid #ccc;'>
        <a href="/admin/site/toggle_page/<?=$page->id?>">
        <img src="<?=$templ_folder?>/images/<?=($page->show ?'lamp-on.png':'lamp-off.png')?>" 
            title="<?php echo $lang['page']['onoff']; ?>" 
            alt="<?php echo $lang['page']['onoff']; ?>" 
            /></a>
    </span>
    

<?/* Изменить порядок */?>   
	
      <span style=''>
         <a href=# 
        onclick="n=prompt('<?=$lang['page']['changeorder_prompt']?>','<?=$page->position?>'); if (n && n!='<?=$page->position?>') location='/admin/site/page_position/<?=$page->id?>/'+n+'?<?=ReturnURL::$suffix?>'; return false;" >
            <img src="<?=$templ_folder?>/images/up_down.png" align=middle style='border:0px solid #ccc;padding:0;'
            
			
			
			<? 
			$tip = str_replace('%order%', $page->position, $lang['page']['change_order']);
			
			?>                
            title="<?=$tip?>"  alt=  "<?=$tip?>" 
        /></a><span style='border:0px solid #ccc; font-size:12px; color:#777;padding-right:5px; width2:30px;' title='<?=$lang['page']['order_tip']?>' ><?=$page->position; ?></span>
    </span>


<?/* Создать подстраницу */?>       

	<span style='border:0px solid #ccc;'>
		<a href="/admin/site/edit_page/?parent_id=<?=$page->id?>&<?=ReturnURL::$suffix?>" >
			<img src="<?=$templ_folder?>/images/add.png" 
			title="Создать подстраницу" 
			/>
		</a>
	</span>
	
	
<?/* Удалить */?>   
	
    <span style='border:0px solid #ccc;'>
        <a href="/admin/site/delete_page/<?=$page->id ?>?<?=ReturnURL::$suffix?>"
		<?
		$page_title = strip_tags($page->title);
		$delete_confirm = html(str_replace('%title%',  $page_title, $lang['page']['delete_confirm'] ));
		?>
		onclick="return confirm('<?=$delete_confirm?>');"
		>
            <img src="<?=$templ_folder?>/images/clear.png" 
            title="<?=$lang['general']['delete']?>" 
            alt = "<?=$lang['general']['delete']?>" />
        </a>
    </span>
	
	
	&nbsp;&nbsp;&nbsp;
	

<?/* Инфо про меню страницы */?>   	
<?if($menu_list = val(Site::$Theme->menu_list)){ ?>

    <a href='/admin/site/edit_page/<?=$page->id ?>/?<?=ReturnURL::$suffix?>#menu_options' title='<?=$lang['general']['change'] ?>' style='text-decoration:none;' ><span class=text6 style='cursor:pointer;'>
   <?=$lang['page']['show_in_menu_pagelist']?>:
   <br>
   <?
	// формируем список меню, на которых отображается страница
	// показываем только те меню, которые указаны в конфиге темы 
	
	$menu_in_page='';
	foreach ($page->show_in_menu as $menu_id)
		if(isset($menu_list[$menu_id]))
			$menu_in_page .= $menu_list[$menu_id] . ', ';
	$menu_in_page= trim( $menu_in_page , ', ');	
	
	echo $menu_in_page;
	
   ?>
    </span></a>
<?}?>    
    
		
</div>

<?php

    show_pages_boxes($page->id);
    



} //end foreach
} //end function show_page_box($page)


?>